package org.zfes.snowier.zbss.xzy.router.device;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.device.model.DeviceChannel;
import org.zfes.snowier.zbss.xzy.biz.device.service.IDeviceChannelService;
import org.zfes.snowier.core.data.SelectVo;
@Controller 
@RequestMapping("/manager/deviceChannel")
public class DeviceChannelController implements BaseController {

	
	@Autowired
	private IDeviceChannelService channelService;
	
	//@RequiresPermissions(value="vedio:loadVedioDataSet",desc="视频列表")
    @RequestMapping(value="/loadChannelDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadChannelDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  channelService.loadVedioDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
    
    @RequestMapping(value="/loadChannelsByDeviceId", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadChannelsByDeviceId(Long deviceId ){
    	List<DeviceChannel> vedioList =  channelService.loadVedioByDeviceId(deviceId, Byte.valueOf("1"));
	    return ajaxQuery("channelList", vedioList);
    }
    
	//@RequiresPermissions(value="vedio:createVedio",desc="视频添加")
    @RequestMapping(value="/createChannel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createChannel( DeviceChannel vedio){
		channelService.createVedio(vedio);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="vedio:loadVedio",desc="视频加载")
    @RequestMapping(value="/loadChannel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadChannel(Long id){
		Optional<DeviceChannel> ops = channelService.loadVedioById(id);
		return ajaxQuery("channel",ops);
    }
	
	//@RequiresPermissions(value="vedio:updateVedio",desc="视频更新")
    @RequestMapping(value="/updateChannel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateChannel(  DeviceChannel vedio){
		channelService.updateVedio(vedio);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="vedio:deletVedio",desc="视频删除")
    @RequestMapping(value="/setChannelStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object setChannelStatus(Long id,Byte status){
		channelService.setVedioStatus(id, status);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    
}